clear all
set more off
set matsize 2000
cd "D:/Dropbox/coauthors/AMT_Bisbee_Larson/bisbee_larson_replication_final"

********************************************************************************
* File Name: relationships_replication.do
* 
* Input Files: final_data_clean.dta
* Output Files: rels_donate_cem.dta
*
* Purpose: This file regresses the donation decisions associated with each 
* elicited tie for each subject on each measure of tie strength between the 
* subject that that tie, using CEM weights to improve precision of the estimates.
********************************************************************************

use ./tools/final_data_clean.dta, clear

matrix betasdiff = J(75	,6,.)
// Donate Test
local i = 1
local depvars = "jobsearch contribute garner personalgain grpgain homo_educ homo_rel homo_pol homo_ls tie_synth pers_cris_synth pers_succ_synth prof_cris_synth prof_cris_synth interaction"
foreach dep of local depvars {
	foreach tie in "weakest""weak""strong""strongest""clique" {
		reg std_donate_`tie' std_`dep'_`tie' [aw=cem_weights] if online == 1, robust
		matrix betasdiff[`i',1] = _b[std_`dep'_`tie']
		matrix betasdiff[`i',2] = _se[std_`dep'_`tie']
		matrix betasdiff[`i',3] = e(N)
		reg std_donate_`tie' std_`dep'_`tie' [aw=cem_weights] if online == 0, robust
		matrix betasdiff[`i',4] = _b[std_`dep'_`tie']
		matrix betasdiff[`i',5] = _se[std_`dep'_`tie']
		matrix betasdiff[`i',6] = e(N)
		local ++i
	}
}
matrix colnames betasdiff = "betaon""seon""Non""betaoff""seoff""Noff"
matrix list betasdiff

preserve
	drop _all
	svmat betasdiff, names(col)
	drop if betaon == .
	input str80 names
	"Job Search Weakest"
	"Job Search Weak"
	"Job Search Strong"
	"Job Search Strongest"
	"Job Search Clique"
	"Contribute to Entrep. Weakest"
	"Contribute to Entrep. Weak"
	"Contribute to Entrep. Strong"
	"Contribute to Entrep. Strongest"
	"Contribute to Entrep. Clique"
	"Garner Contributions Weakest"
	"Garner Contributions Weak"
	"Garner Contributions Strong"
	"Garner Contributions Strongest"
	"Garner Contributions Clique"
	"Personal Gain (% of $100) Weakest"
	"Personal Gain (% of $100) Weak"
	"Personal Gain (% of $100) Strong"
	"Personal Gain (% of $100) Strongest"
	"Personal Gain (% of $100) Clique"
	"Group Gain (% of $100) Weakest"
	"Group Gain (% of $100) Weak"
	"Group Gain (% of $100) Strong"
	"Group Gain (% of $100) Strongest"
	"Group Gain (% of $100) Clique"
	"Education Homophily Weakest"
	"Education Homophily Weak"
	"Education Homophily Strong"
	"Education Homophily Strongest"
	"Education Homophily Clique"
	"Religion Homophily Weakest"
	"Religion Homophily Weak"
	"Religion Homophily Strong"
	"Religion Homophily Strongest"
	"Religion Homophily Clique"
	"Political Homophily Weakest"
	"Political Homophily Weak"
	"Political Homophily Strong"
	"Political Homophily Strongest"
	"Political Homophily Clique"
	"Class Homophily Weakest"
	"Class Homophily Weak"
	"Class Homophily Strong"
	"Class Homophily Strongest"
	"Class Homophily Clique"
	"Tie Strength Weakest"
	"Tie Strength Weak"
	"Tie Strength Strong"
	"Tie Strength Strongest"
	"Tie Strength Clique"
	"Personal Crisis Weakest"
	"Personal Crisis Weak"
	"Personal Crisis Strong"
	"Personal Crisis Strongest"
	"Personal Crisis Clique"
	"Personal Success Weakest"
	"Personal Success Weak"
	"Personal Success Strong"
	"Personal Success Strongest"
	"Personal Success Clique"
	"Professional Crisis Weakest"
	"Professional Crisis Weak"
	"Professional Crisis Strong"
	"Professional Crisis Strongest"
	"Professional Crisis Clique"
	"Professional Success Weakest"
	"Professional Success Weak"
	"Professional Success Strong"
	"Professional Success Strongest"
	"Professional Success Clique"
	"Preferred Interaction Weakest"
	"Preferred Interaction Weak"
	"Preferred Interaction Strong"
	"Preferred Interaction Strongest"
	"Preferred Interaction Clique"
	g names2 = substr(names,strlen(names)-8,100)
	g names3 = substr(names2,strpos(names2," "),100)
	replace names3 = names2 if names3 == ""
	saveold "./relationships/rels_donate_cem.dta", replace
restore
